from PyQt5 import QtWidgets,QtCore


class ChooseUserClass(QtWidgets.QDialog):
    def __init__(self,users):
        QtWidgets.QDialog.__init__(self)
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
        self.user_list=QtWidgets.QComboBox()
        self.ok_btn=QtWidgets.QPushButton('确认登录')
        self.cancel_btn=QtWidgets.QPushButton('取消登录')
        self.main_layout=QtWidgets.QVBoxLayout()
        self.bottom_layout=QtWidgets.QHBoxLayout()
        self.main_layout.addWidget(self.user_list)
        self.main_layout.addLayout(self.bottom_layout)
        self.bottom_layout.addWidget(self.ok_btn)
        self.bottom_layout.addWidget(self.cancel_btn)
        self.setLayout(self.main_layout)
        for name in users:
            self.user_list.addItem(name[0])
        self.ok_btn.clicked.connect(self.on_ok_clicked)
        self.cancel_btn.clicked.connect(self.on_cancel_clicked)

    def on_ok_clicked(self):
        self.done(1)

    def on_cancel_clicked(self):
        self.done(0)
